package com.hfkh.keyun.controller.frontend;


import com.hfkh.keyun.common.ApiResult;
import com.hfkh.keyun.entity.Carousel;
import com.hfkh.keyun.service.CarouselService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/app/carousel")
@Api(tags = "轮播图管理")
public class CarouselControllerApp {

    @Resource
    private CarouselService carouselService;

    @ApiOperation("查询所有轮播列表")
    @GetMapping("/selCarousel")
    public ApiResult selCarousel(){
        Map<String ,Object> map=new HashMap<>();
        map.put("delete_flags",0);
        List<Carousel> carousels = carouselService.listByMap(map);
        return ApiResult.success(carousels);
}

    @ApiOperation("按数量查询轮播列表")
    @GetMapping("/top")
    @ApiImplicitParam(name = "num",value = "数量",required = true,paramType = "query",dataType = "String",defaultValue ="3")
    public ApiResult topList(Integer num){
        List<Carousel> carouselList = carouselService.findByLimit(num);
        return ApiResult.success(carouselList);
    }

}
